package com.amigo.online.provider.manager.util;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolUtil {

    public static void main(String[] args) {

        createFixThreadPool();
    }

    private static void createFixThreadPool() {


        ExecutorService executorService = Executors.newFixedThreadPool(10);

        for (int e = 0; e < 10; e++) {
            final int index = e;
            executorService.execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                    System.out.println(Thread.currentThread().getName() + "=执行了==" + index);

                }
            });

        }


        executorService.shutdown();
        System.out.println(Thread.currentThread().getName() + "===over====");

    }
}
